﻿using BCCommon;
using BCDto.TMS.VehicleTransportFaqCategory;
using BCService.TMS.VehicleTransportFaqCategory;
using BCTMSRESTful.Configs;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BCTMSRESTful.Controllers.Management.TMS.VehicleTransportFaqCategory
{

    /// <summary>
    /// 车辆运输问题分类接口
    /// </summary> 
    [ApiExplorerSettings(GroupName = "TMSAdmin")]
    [Route("api/v1/sim/[controller]")]
    public class VehicleTransportFaqCategoryController : ManagementBaseController
    {
        #region var
        private IVehicleTransportFaqCategoryService vehicleTransportFaqCategoryService;
        #endregion


        #region 构造函数
        /// <summary>
        /// 构造函数
        /// </summary> 
        public VehicleTransportFaqCategoryController(IVehicleTransportFaqCategoryService vehicleTransportFaqCategoryService)
        {
            this.vehicleTransportFaqCategoryService = vehicleTransportFaqCategoryService;
        }
        #endregion

        #region POST 添加  
        /// <summary>
        /// 添加新车辆运输问题分类纪录
        /// </summary>
        /// <param name="dto">车辆运输问题分类数据模型</param>
        /// <returns></returns>
        [Log("添加新车辆运输问题分类纪录")]
        [HttpPost]
        [ProducesResponseType(typeof(VehicleTransportFaqCategoryRequestDto), 200)]
        public IActionResult Post([FromBody] VehicleTransportFaqCategoryRequestDto dto)
        {
            var a = vehicleTransportFaqCategoryService.Add(dto, this.Admin);
            return Ok(a);
        }

        #endregion

        #region PUT 修改   
        /// <summary>
        /// 修改车辆运输问题分类纪录
        /// </summary>
        /// <param name="dto">车辆运输问题分类数据模型</param>
        /// <returns></returns>
        [Log("修改车辆运输问题分类纪录")]
        [HttpPut]
        [ProducesResponseType(typeof(VehicleTransportFaqCategoryDto), 200)]
        public IActionResult Put([FromBody] VehicleTransportFaqCategoryDto dto)
        {
            var a = Ok(vehicleTransportFaqCategoryService.Update(dto, this.Admin));
            return a;
        }
        #endregion

        #region 删除  
        /// <summary>
        /// 删除车辆运输问题分类纪录
        /// </summary>
        /// <param name="vehicleTransportFaqCategoryId">车辆运输问题分类ID</param>
        /// <returns></returns>
        [Log("删除车辆运输问题分类纪录")]
        [HttpDelete("{vehicle_transport_faq_category_id}")]
        [ProducesResponseType(typeof(NoContentResult), 204)]
        public IActionResult Delete([FromRoute(Name = "vehicle_transport_faq_category_id")] long vehicleTransportFaqCategoryId)
        {
            vehicleTransportFaqCategoryService.Delete(vehicleTransportFaqCategoryId);
            return NoContent();
        }
        #endregion

        #region GetByID     
        /// <summary>
        /// 获取一条车辆运输问题分类纪录
        /// </summary>
        /// <param name="vehicleTransportFaqCategoryId">车辆运输问题分类ID</param>
        /// <returns></returns>
        [HttpGet("{vehicle_transport_faq_category_id}")]
        [ProducesResponseType(typeof(VehicleTransportFaqCategoryDto), 200)]
        public IActionResult Get([FromRoute(Name = "vehicle_transport_faq_category_id")] long vehicleTransportFaqCategoryId)
        {
            return (Ok(vehicleTransportFaqCategoryService.GetById(vehicleTransportFaqCategoryId)));

        }
        #endregion

        #region Query 查询车辆运输问题分类

        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<VehicleTransportFaqCategoryDto>), 200)]
        public IActionResult Query(
            [FromQuery(Name ="faq_category")] string faqCategory,
            [FromQuery(Name = "index")] int? pageIndex = 1, 
            [FromQuery(Name = "size")] int? pageSize = 10)
        {
            var a = Ok(vehicleTransportFaqCategoryService.GetList(faqCategory,pageIndex.Value, pageSize.Value));
            return a;
        }
        #endregion
    }

}
